<template>
  <div class="regist_container">
    <div class="regist_box">
      <div class="regist_content">
        <div class="to_regist">
          <span class="to_regist_text">账号已经存在？</span>
          <el-button type="primary" size="small" @click="tologin">登陆</el-button>
        </div>
        <div class="regist_content_form">
          <div class="regist_from_content">
            <p class="slogan">注册</p>
            <el-form label-position="top"
                     :model="ruleForm"
                     :rules="rules"
                     ref="ruleForm">
              <el-form-item class="label" label="请输入新的用户名" prop="username" >
                <el-input v-model="ruleForm.username" placeholder="请输入用户名"></el-input>
              </el-form-item>
              <el-form-item class="label" label="请输入密码" prop="password">
                <el-input class="label" v-model="ruleForm.password" placeholder="请输入密码"></el-input>
              </el-form-item>
              <el-form-item class="label" label="请再次确认密码" prop="newpassword">
                <el-input v-model="ruleForm.newpassword" placeholder="请再次确认密码"></el-input>
              </el-form-item>
              <el-form-item class="label" label="请输入昵称" prop="nickname">
                <el-input v-model="ruleForm.nickname" placeholder="请输入昵称"></el-input>
              </el-form-item>
              <el-form-item class="label"  prop="verification">
                <el-input class="security_num" v-model="ruleForm.verification" placeholder="请输入验证码"></el-input>
                <div class="verification_img">
                  这是验证码
                </div>
              </el-form-item>

            </el-form>
            <el-button type="primary" class="regist_btn" @click="submitForm('ruleForm')">注册</el-button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "Logout",
  data() {
    return {
      ruleForm: {
        username: '',
        password: '',
        newpassword:'',
        nickname:'',
        verification:'',
      },
      rules:{
        username: [
          { required: true, message: '请输入用户名', trigger: 'blur' },
        ],
        password: [
          { required: true, message: '请输入密码', trigger: 'blur' }
        ],
        newpassword: [
          { required: true, message: '请再次输入密码', trigger: 'blur' }
        ],
        nickname: [
          { required: true, message: '请输入昵称', trigger: 'blur' }
        ],
        verification: [
          { required: true, message: '请输入用户名', trigger: 'blur' }
        ]
      },
      checked:false,
    };
  },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert('submit!');
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    tologin(){
      this.$router.push('/login')
    }
  }
}
</script>


<style >
.regist_container {
  height: 100vh;
  width: 100vw;
  background-image: linear-gradient(90deg, #3B73F0, #A5C1FF);
  display: flex;
  flex-direction: row-reverse;
}

.regist_container .regist_box {
  width: 50%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  /*background-color: pink;*/
}

.regist_container .regist_box .regist_content {
  width: 600px;
  height: 600px;
  background-color: #fff;
  border-radius: 10px;
  position: relative;
}

.regist_container .regist_box .regist_content .to_regist {
  width: 100%;
  height: 60px;
  display: flex;
  padding: 20px;
  justify-content: flex-end;
  align-items: center;

}

.regist_container .regist_box .regist_content .to_regist .to_regist_text {
  font-size: 12px;
  color: #1F1D2B;
  margin-bottom: 0;
  margin-right: 10px;
}

.regist_container .regist_box .regist_content .regist_content_form {
  width: 100%;
  height: 540px;
  position: absolute;
  top: 60px;
  padding:  0 100px;
  display: flex;
  align-items: center;
}
.label .el-form-item__label
{
  padding: 0px;
}


.slogan
{
  text-align: center;
  font-size: 26px;
  color: #3B73F0;
  font-weight: bold;
}

.regist_from_content
{
  width: 400px  ;
  position: absolute;
  top: -20px;
}

.verification_img
{
  background-color: cornflowerblue;
  float: right;
  width: 180px;
  height: 40px;
  color: white;
  text-align: center;
}

.regist_btn
{
  width: 100%;
  background-image: linear-gradient(90deg, #3B73F0, #A5C1FF);
}

.regist_btn:hover
{
  opacity:0.8;
}

.security_num
{
  width: 50%;
}
</style>
